package hessingerbg.gui;

import java.awt.Color;
import java.util.HashMap;

import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import net.java.dev.designgridlayout.DesignGridLayout;

public class Panel extends JPanel {

	Color background = Color.LIGHT_GRAY;
	String Name;
	HashMap<String, JComponent> Data = new HashMap<String, JComponent>();
        private DesignGridLayout panes[] = new DesignGridLayout[3];

	public Panel()
	{
		//this.setBackground(background);
		setUpFields();
		Name = "NULL";
	}

	public Panel(int width, int height)
	{
		this.setSize(width, height);
		//this.setBackground(background);
		setUpFields();
		Name = "NULL";
	}

	public Panel(String title)
	{
                //this.setBackground(background);
                setUpFields();
            Name = title;
	}

	@Override
	public String getName()
	{
		return Name;
	}

	protected void setUpFields() {
            
            DesignGridLayout layout = new DesignGridLayout(this);
            JPanel left = new JPanel();
            JPanel right = new JPanel();
            left.setVisible(true);
            right.setVisible(true);
            layout.row().center().add(left).add(right).fill();
            panes[0] = new DesignGridLayout(left);
            panes[1] = new DesignGridLayout(right);
	}

        public void addComponent(int zone, JComponent comp, String name )
        {
           panes[zone].row().grid(new JLabel(name + ": ")).add(comp);
           Data.put(name, comp);
        }

        public void addComponent(int zone, JComponent comp, JComponent comp2, String name, String name2, boolean describer )
        {
            if(describer)
                panes[zone].row().grid(new JLabel(name + ": ")).add(comp).grid(new JLabel(name2 + ": ")).add(comp2);
            else
                panes[zone].row().grid().add(comp).add(comp2);
            Data.put(name, comp);
            Data.put(name2, comp2);
        }

        public void reverseLockAllComponents()
        {
            for(JComponent x : Data.values())
            {
                x.setEnabled(!x.isEnabled());
            }
        }
}
